package cn.wb.user.controller;

import cn.wb.base.util.AjaxResult;
import cn.wb.user.dto.AccountLoginDto;
import cn.wb.user.dto.BinderDto;
import cn.wb.user.dto.WechatDto;
import cn.wb.user.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 登录接口
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 账号密码登录
     * @param dto
     * @return
     */
    @PostMapping("/account")
    public AjaxResult account(@RequestBody @Valid AccountLoginDto dto)
    {
        return loginService.account(dto);
    }

    /**
     * 微信登录
     * @param
     * @return
     */
    @PostMapping("/wechat")
    public AjaxResult wechat(@RequestBody @Valid WechatDto dto)
    {
        return loginService.wechat(dto);
    }

    /**
     * 绑定
     * @param
     * @return
     */
    @PostMapping("/wechat/binder")
    public AjaxResult binder(@RequestBody @Valid BinderDto dto)
    {
        return loginService.binder(dto);
    }
}
